package com;


import com.data.structure.node.MyVector;
import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
import javafx.scene.layout.BackgroundImage;

import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * Created by lucky on 2018/9/20.
 */
public class Main {
    public static void main(String[] args) throws Exception{
//        MyVector<Integer> vector = new MyVector<>(20);
//        for ( int i = 1 ; i <= 20 ; i ++)
//            vector.pushBack(i);

//        System.out.println("我的vector:pop"+vector.popBack());
//
//        System.out.println("获取第15个元素："+ vector.get(15));

//        long startTime = System.currentTimeMillis();
//        MyVector<Integer> vector = new MyVector<>();
//        for ( int i = 1 ; i <= 10000000 ; i ++){
//            vector.pushBack(i);
//        }
//
//        for ( int i = 1 ; i <= 10000000 ; i ++){
//            vector.popBack();
//        }
//        System.out.println("耗时为: "+ (System.currentTimeMillis() - startTime)/1000 + "s");
//
//        int a = 12321;
//        int b = a /10000;
//        int c = a /1000 % 10;
//        System.out.println(b);
//        System.out.println(c);
//
//        Double d = 245.005d;
//        Double f = d/ 0.5;
//        Double g = d%0.5;
//        System.out.println(f);
//        System.out.println(g);
//        if(d / 0.5 == 0){
//            System.out.println("ok");
//        }
//        if(d % 0.5 == 0){
//            System.out.println("ok");
//        }

//        System.out.println(10%0.1);
//
//        BigDecimal stop = new BigDecimal("369.00");
//        if(stop.compareTo(new BigDecimal(stop.intValue())) == 0){
//            System.out.println("yes");
//        }else{
//            System.out.println("no");
//        }
//        stop = stop.setScale(2,BigDecimal.ROUND_DOWN);
//        BigDecimal multiply = stop.multiply(new BigDecimal(Math.pow(10, 2)));
//        BigDecimal[] bigDecimals = multiply.divideAndRemainder(new BigDecimal(5));
//        System.out.println(bigDecimals[0]);
//        System.out.println(bigDecimals[1]);

//        BigDecimal divide = new BigDecimal(3).divide(new BigDecimal(100),BigDecimal.ROUND_DOWN).setScale(2);
//        System.out.println(divide);
//        Double d = 21d;
//        if("20001,20002".contains("20001")&&d % 5 != 0){
//            System.out.println(1);
//        }
//        String num = "45.05";
//        Double aDouble = new Double(num);
//        System.out.println(aDouble+"");

        String a =  (~0+2) + "";
        System.out.println(a);

//        System.out.println( (51 + 20 -1) / 20);
//
//        double t = 343.45 + 20 * 0.01;
//        System.out.println(t);
//        BigDecimal s = new BigDecimal(343.65);
//        String m = s.add(new BigDecimal(20).multiply(new BigDecimal(0.01))).setScale(2,BigDecimal.ROUND_HALF_UP).toString();
//        System.out.println(m);
////        int l = d % 5;
////        System.out.println(l);
//
//        if(new BigDecimal(1).compareTo(new BigDecimal(2)) < 0){
//            System.out.println(1);
//        }
        BigDecimal bigDecimal = new BigDecimal("5.26449894E-315");
        System.out.println(bigDecimal.toPlainString());

        List<Integer> list =new ArrayList<>();
        for (int i = 0 ; i < 1000; i++){
            list.add(i);
        }
        int len = list.size();
        if(len > 500){
            int i = 0;
            for(i=0;i< (int)((len-1)/500);i++){
                List<Integer> lista = list.subList(i*500, (i+1)*500);
                lista.forEach(x->{
                    System.out.print(x+",");
                });
                System.out.println();
            }
            List<Integer> listb = list.subList(i*500, len);
            listb.forEach(x->{
                System.out.print(x+",");
            });
        }

        String str = "abcdefg";
        String reverse = reverse(str);
        System.out.println(reverse);

        System.out.println(System.currentTimeMillis());
        System.out.println(UUID.randomUUID().toString());
        String s = UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis();
        System.out.println(s.length());
        System.out.println(s);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar instance = Calendar.getInstance();
        instance.setTime(simpleDateFormat.parse("2020-06-02 00:00:00"));
        int i = instance.get(Calendar.DAY_OF_WEEK);
        System.out.println(i);

        String su = "2345.1";
        System.out.println(su.substring(0,1));
    }

    public static String reverse(String originStr) {
        if(originStr == null || originStr.length() <= 1)
            return originStr;
        return reverse(originStr.substring(1)) + originStr.charAt(0);
    }
}
